package easytodo.model;

import java.util.ArrayList;
import android.os.Parcel;
import android.os.Parcelable;

public class Note implements Parcelable {
	// Database columns
	public int ID;
	public CharSequence Title;
	public CharSequence Content;
	public Long Created;
	public Long Modified;
	public int CategoryID;
	public int PriorityID;

	// "Calculated" from DB.
	public String CategoryName;
	public int PriorityValue;
	public ArrayList<String> Tags;

	public int describeContents() {
		return 0;
	}

	public static final Parcelable.Creator<Note> CREATOR = new Parcelable.Creator<Note>() {
		public Note createFromParcel(Parcel in) {
			return new Note(in);
		}

		public Note[] newArray(int size) {
			return new Note[size];
		}
	};

	private Note(Parcel in) {
		readFromParcel(in);
	}

	private void readFromParcel(Parcel in) {
		ID = in.readInt();
		Title = in.readString();
		Content = in.readString();
		Created = in.readLong();
		Modified = in.readLong();
		CategoryID = in.readInt();
		PriorityID = in.readInt();
	}

	public void writeToParcel(Parcel out, int flags) {
		out.writeInt(ID);

		if (Title != null)
			out.writeString(Title.toString());
		else
			out.writeString("");

		if (Content != null)
			out.writeString(Content.toString());
		else
			out.writeString("");

		if (Created != null)
			out.writeLong(Created);
		else
			out.writeLong(0);

		if (Modified != null)
			out.writeLong(Modified);
		else
			out.writeLong(0);

		out.writeInt(CategoryID);
		out.writeInt(PriorityID);
	}

	public Note() {

	}
}
